﻿
using System ;
using System.Windows.Forms ;

using MskEdit.Dxf.Model ;


namespace MskEdit.Dxf.Frontend
{

    public class DxfBlocksTreeNode : TreeNode 
    {
        private DxfBlocks dxfBlocks_ ;
        
        
        public static DxfBlocksTreeNode TryFrom( DxfBlocks dxfBlocks, DxfBlocksTreeNode fallbackValue ) {
        
            if ( dxfBlocks == null )
                return fallbackValue ;
                
            return new DxfBlocksTreeNode( dxfBlocks ) ;
        }
        
        
        public DxfBlocksTreeNode( DxfBlocks dxfBlocks ) {
        
            dxfBlocks_ = dxfBlocks ;
            this.Text = "Blocks " ;
                
            foreach ( var dxfBlock in dxfBlocks_.Blocks ) {
                
                DxfBlockTreeNode dxfBlockTreeNode = DxfBlockTreeNode.TryFrom( dxfBlock, null ) ;
                if ( dxfBlockTreeNode == null )
                    continue ;
                    
                this.Nodes.Add( dxfBlockTreeNode ) ;
            }
        }
    }
}
